package org.geek.week2.java0.nio01.client;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

import java.io.IOException;

/**
 * @create 2021/9/25
 */
public class OkHttpClientServer {
    public static void main(String[] args) throws IOException {
        String url = "http://127.0.0.1:8808";
        OkHttpClient client = new OkHttpClient();
        final Request request = new Request.Builder()
                .url(url)
                .build();
        final Call call = client.newCall(request);
        final Response execute = call.execute();
        final ResponseBody body = execute.body();
        final byte[] bytes = body.bytes();
        String bodyContent = new String(bytes,"utf-8");
        System.out.println(url+" 返回结果:"+bodyContent);
    }
}
